package com.stlm2.dems.user.entity;

import com.stlm2.dems.entity.User;

import java.io.Serializable;

/**
 * 用于保存登录用户信息
 */
public class Login implements Serializable{
    private String name;

    private String pwd;
    private String host;

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    /**
     * 从User转换
     * @param user
     * @return
     */
    public static Login from(User user,String host){
        if(user == null || UserState.Invalid.equals(user.getUserState()))
            return null;

        Login login = new Login();
        login.setName(user.getName());
        login.setPwd(user.getPassword());
        login.setHost(host);
        return login;
    }
}
